//
//  UserSafetyViewController.m
//  JinYong_iOS_Store
//
//  Created by 王厚一 on 2017/10/22.
//  Copyright © 2017年 why. All rights reserved.
//


#import "UserSafetyViewController.h"
#import "ResetPasswdViewController.h"

@interface UserSafetyViewController ()

@end

@implementation UserSafetyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = RGB(240, 240, 240);
    
    [self addTopView];
    [self createUI];
}

#pragma mark - --------------添加头视图----------------
- (void)addTopView{
    UIView * topView = ({
        UIView * view = [[UIView alloc] initWithFrame:CGRectMake(ActualW(0), ActualH(0), ActualW(375), ActualH(64))];
        CAGradientLayer * gradientLayer = [CAGradientLayer layer];
        gradientLayer.frame = view.bounds;
        //设置渐变区域的起始和终止位置（范围为0-1）
        gradientLayer.startPoint = CGPointMake(0, 0);
        gradientLayer.endPoint = CGPointMake(1, 0);
        //设置颜色数组
        gradientLayer.colors = @[(__bridge id)RGB(22, 125, 255).CGColor, (__bridge id)RGB(0, 178, 255).CGColor];
        //设置颜色分割点（范围：0-1）
        gradientLayer.locations = @[@(0.0f), @(1.0f)];
        [view.layer addSublayer:gradientLayer];
        view;
    });
    [self.view addSubview:topView];
    
    
    UILabel * title = ({
        UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(ActualW(152.5), ActualH(32), ActualW(72), ActualH(17))];
        label.textColor = RGB(255, 255, 255);
        label.textAlignment = NSTextAlignmentLeft;
        label.text = @"账户安全";
        label.font = FontX(FONTSIZE(17));
        label;
    });
    [topView addSubview:title];
    
    UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(ActualW(10), ActualH(31.5), ActualW(18), ActualH(18))];
    imageView.image = [UIImage imageNamed:@"back"];
    [topView addSubview:imageView];
    
    
    UIButton * backButton = [[UIButton alloc] initWithFrame:CGRectMake(ActualW(0), ActualH(13.5), ActualW(41), ActualH(44))];
    [backButton addTarget:self action:@selector(popAction) forControlEvents:UIControlEventTouchUpInside];
    
    [topView addSubview:backButton];

}


- (void)createUI {
    UIView * breakView = ({
        UIView * view = [[UIView alloc] initWithFrame:CGRectMake(ActualW(0), ActualH(64), ActualW(375), ActualH(10))];
        view.backgroundColor = RGB(240, 240, 240);
        view;
    });
    [self.view addSubview:breakView];
    
    
    for (int i = 0; i < 1; i++) {
        
        UIButton * sender = ({
            UIButton * button = [[UIButton alloc] initWithFrame:CGRectMake(ActualW(0), ActualH(76) + i * ActualH(45), ActualW(375), ActualH(45))];
            [button addTarget:self action:@selector(enterAction:) forControlEvents:UIControlEventTouchUpInside];
            button.backgroundColor = [UIColor whiteColor];
            button.tag = i + 5000;
            button;
        });
        [self.view addSubview:sender];
        
        NSArray * titles = @[@"修改密码"];
        UILabel * name = ({
            UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(ActualW(10), ActualH(15.5), ActualW(130), ActualH(15))];
            label.textColor = RGB(76, 78, 98);
            label.text = titles[i];
            label.backgroundColor = RGB(255, 255, 255);
            label.textAlignment = NSTextAlignmentLeft;
            label.font = FontX(FONTSIZE(14));
            label;
        });
        [sender addSubview:name];
        
        UIImageView * enterImage = [[UIImageView alloc] initWithFrame:CGRectMake(ActualW(356), (CGRectGetHeight(sender.frame) - ActualH(12)) / 2, ActualW(7.5), ActualH(12))];
        enterImage.image = [UIImage imageNamed:@"Common_next"];
        [sender addSubview:enterImage];
        
        if (i == 0) {
            UIView * breakLine = ({
                UIView * view = [[UIView alloc] initWithFrame:CGRectMake(ActualW(10), ActualH(44), ActualW(355), ActualH(1))];
                view.backgroundColor = RGB(239, 239, 239);
                view;
            });
            [sender addSubview:breakLine];
        }
    }
}

- (void)enterAction:(UIButton *)sender {
    [self enterPasswd];
}

- (void)enterPasswd {
    ResetPasswdViewController * vc = [[ResetPasswdViewController alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
}


- (void)popAction {
    [self.navigationController popViewControllerAnimated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
